<?php
/**
 * Copyright (C), 2021-2021, Shall Buy Life info. Co., Ltd.
 * FileName: RmqConsumerCommand.php
 * Description: 说明
 *
 * @author lwl
 * @Create Date    2021/11/10 13:25
 * @Update Date    2021/11/10 13:25 By lwl
 * @version v1.0
 */
namespace App\Console\Commands;

use App\Services\RmqClientService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class RmqConsumerCommand extends Command
{
    protected $signature = 'withdrawal:consumer';
    protected $description = '消费提现审核通过后的消息';

    public function handle()
    {
        while (true) {
            $service = RmqClientService::getInstance();
            $queue = config('queue.connections.rabbitmq.queue');
            $response = $service->consumer($queue, true);
            if (!is_null($response)) {
                $result = json_decode($response->body,1);
                DB::table('examples')->insert(['title'=>'lwl']);
                //dd($result);
            }
            Log::info('没有可消费消息');
        }

    }
}
